<?php

namespace Apps\Common\Models;

/**
 * 美容院Model
 * @author     chenxiaolin
 * @date        2016年1月19日
 * @version     2.0.0
 * @copyright   Copyright 2016 meelier.com
 */
class BeautyParlor extends \PhalconPlus\Database\Model
{

    /**
     *
     * @var integer
     */
    public $bp_id;

    /**
     *
     * @var string
     */
    public $bp_name;

    /**
     *
     * @var string
     */
    public $bp_cover;

    /**
     *
     * @var string
     */
    public $bp_address;

    /**
     *
     * @var integer
     */
    public $bp_district;

    /**
     *
     * @var integer
     */
    public $bp_coordinate;

    /**
     *
     * @var string
     */
    public $bp_tel;

    /**
     *
     * @var string
     */
    public $bp_intro;

    /**
     *
     * @var integer
     */
    public $bp_state;

    /**
     *
     * @var integer
     */
    public $bp_is_sell;

    /**
     *
     * @var string
     */
    public $bp_medal;

    /**
     *
     * @var integer
     */
    public $bp_owner_mobile;

    /**
     *
     * @var string
     */
    public $bp_addtime;
    public $branch_id;
    public $long_time;
    
    public $end_time;
    
    public $start_time;
    public $lon;
    public $lat;
    public $city_code;

    /**
     * Initialize method for model.
     */
    public function initialize()
    {
        $this->hasMany('bp_id', 'Apps\Common\Models\ActivityBeautyParlor', 'beauty_parlor_id', array('alias' => 'ActivityBeautyParlor'));
        $this->hasMany('bp_id', 'Apps\Common\Models\BeautyParlorComment', 'beauty_parlor_id', array('alias' => 'BeautyParlorComment'));
        $this->hasMany('bp_id', 'Apps\Common\Models\BeautyParlorPhotos', 'beauty_parlor_id', array('alias' => 'BeautyParlorPhotos'));
        $this->hasMany('bp_id', 'Apps\Common\Models\BeautyParlorService', 'beauty_parlor_id', array('alias' => 'BeautyParlorService'));
        $this->hasMany('bp_id', 'Apps\Common\Models\BeautyParlorTag', 'bp_id', array('alias' => 'BeautyParlorTag'));
    }

    /**
     * Returns table name mapped in the model.
     *
     * @return string
     */
    public function getSource()
    {
        return 'beauty_parlor';
    }

    /**
     * Allows to query a set of records that match the specified conditions
     *
     * @param mixed $parameters
     * @return BeautyParlor[]
     */
    public static function find($parameters = null)
    {
        return parent::find($parameters);
    }

    /**
     * Allows to query the first record that match the specified conditions
     *
     * @param mixed $parameters
     * @return BeautyParlor
     */
    public static function findFirst($parameters = null)
    {
        return parent::findFirst($parameters);
    }

    /**
     * Independent Column Mapping.
     * Keys are the real names in the table and the values their names in the application
     *
     * @return array
     */
    public function columnMap()
    {
        return array(
            'bp_id' => 'bp_id',
            'bp_name' => 'bp_name',
            'bp_cover' => 'bp_cover',
            'bp_address' => 'bp_address',
            'bp_district' => 'bp_district',
            'bp_coordinate' => 'bp_coordinate',
            'bp_tel' => 'bp_tel',
            'bp_intro' => 'bp_intro',
            'bp_state' => 'bp_state',
            'bp_is_sell' => 'bp_is_sell',
            'bp_medal' => 'bp_medal',
            'bp_owner_mobile' => 'bp_owner_mobile',
            'bp_addtime' => 'bp_addtime',
        	'branch_id'=>'branch_id',
        	'long_time'=>'long_time',
        	'start_time'=>'start_time',
        	'end_time'=>'end_time',
        	'lon'=>'lon',
        	'lat'=>'lat',
        	'city_code'=>'city_code'
        );
    }

    public function defaultColumns()
    {
        return [
            'bp_state',
            'bp_medal',
            'bp_owner_mobile',
            'bp_addtime',
        ];
    }

}
